package com.sheledon.flyCat.core.resolver;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sheledon.flyCat.common.pojo.MethodDetail;

import java.lang.reflect.Parameter;

/**
 * @author sheledon
 */
public class RequestBodyParameterResovler implements ParameterResolver{
    @Override
    public Object resolve(MethodDetail methodDetail, Parameter parameter) {
        ObjectMapper om = new ObjectMapper();
        try {
            return om.readValue(methodDetail.getJson(),parameter.getType());
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return null;
    }
}
